/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * BuscadorImagenes.java
 *
 * Created on 17/05/2010, 12:06:51 PM
 */

package administrador;

import java.awt.Dimension;
import java.math.RoundingMode;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JScrollBar;

/**
 *
 * @author daniel1
 */
public class pedidoReposicion extends javax.swing.JFrame {
Conexion conexion;
String bodega;
Usuario user;

String observacion;

//Nath Redondeo
    NumberFormat nf = NumberFormat.getNumberInstance();

    /** Creates new form BuscadorImagenes */
    public pedidoReposicion(Conexion conexion,String bEnt,Usuario user,String obs,String fecha,String cod_ped) {

        initComponents();
        this.conexion=conexion;
        bodega=bEnt;
        this.user=user;
        //muestroCategorias();

        setBounds(50,50,1020,600);
        
        //Configuro Redondeo
        nf.setMaximumFractionDigits(0);
        nf.setRoundingMode(RoundingMode.FLOOR);

        //Hago visible
        this.setVisible(true);

        //cargoDatos de la ventana
        cargoDatosVent(obs,fecha,cod_ped);
        this.muestraTodos();

    }

   public void  cargoDatosVent(String obs,String fecha,String cod_ped){
      //Cargos Datos del Pedido si viene de la Ventana Nueva:
        observacion=obs;
        txt_fecha.setText(fecha);
        txt_cod.setText(cod_ped);
        txt_bod.setText(String.valueOf(bodega));

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txt_buscar = new javax.swing.JTextField();
        cb_cantidad = new javax.swing.JCheckBox();
        jButton1 = new javax.swing.JButton();
        sc_principal = new javax.swing.JScrollPane();
        contenedor = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        txt_numero = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txt_cod = new javax.swing.JTextField();
        txt_fecha = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txt_bod = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(administrador.AdministradorApp.class).getContext().getResourceMap(pedidoReposicion.class);
        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        txt_buscar.setText(resourceMap.getString("txt_buscar.text")); // NOI18N
        txt_buscar.setName("txt_buscar"); // NOI18N
        txt_buscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_buscarKeyTyped(evt);
            }
        });

        cb_cantidad.setText(resourceMap.getString("cb_cantidad.text")); // NOI18N
        cb_cantidad.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        cb_cantidad.setMargin(new java.awt.Insets(0, 0, 0, 0));
        cb_cantidad.setName("cb_cantidad"); // NOI18N
        cb_cantidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_cantidadActionPerformed(evt);
            }
        });

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        sc_principal.setName("sc_principal"); // NOI18N

        contenedor.setName("contenedor"); // NOI18N
        contenedor.setPreferredSize(new java.awt.Dimension(872, 5000));

        javax.swing.GroupLayout contenedorLayout = new javax.swing.GroupLayout(contenedor);
        contenedor.setLayout(contenedorLayout);
        contenedorLayout.setHorizontalGroup(
            contenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 872, Short.MAX_VALUE)
        );
        contenedorLayout.setVerticalGroup(
            contenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 5000, Short.MAX_VALUE)
        );

        sc_principal.setViewportView(contenedor);

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setForeground(resourceMap.getColor("jLabel2.foreground")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        txt_numero.setFont(resourceMap.getFont("txt_numero.font")); // NOI18N
        txt_numero.setName("txt_numero"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        txt_cod.setEditable(false);
        txt_cod.setText(resourceMap.getString("txt_cod.text")); // NOI18N
        txt_cod.setName("txt_cod"); // NOI18N
        txt_cod.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_codActionPerformed(evt);
            }
        });

        txt_fecha.setEditable(false);
        txt_fecha.setText(resourceMap.getString("txt_fecha.text")); // NOI18N
        txt_fecha.setName("txt_fecha"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        txt_bod.setText(resourceMap.getString("txt_bod.text")); // NOI18N
        txt_bod.setEnabled(false);
        txt_bod.setName("txt_bod"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sc_principal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 713, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txt_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel6))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txt_numero, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(cb_cantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel1)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txt_fecha)
                                    .addComponent(txt_cod, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txt_bod, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(17, 17, 17))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txt_cod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(txt_bod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txt_fecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(3, 3, 3)
                        .addComponent(txt_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txt_numero, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cb_cantidad))
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(sc_principal, javax.swing.GroupLayout.DEFAULT_SIZE, 423, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
 public void muestroCategorias(){

     ResultSet r=conexion.consultarBase("select * from categoria");
     try{
            r.beforeFirst();
           // cb_categoria.addItem("Todas Categorias");
            while(r.next()){
            String catS=r.getString(2);
           // cb_categoria.addItem(catS);
            }

        }
       catch(SQLException sqle){
            System.out.println("Error al mostrar Bodegas");
            System.err.println(sqle);
        }


    }String txt_cantidad="";
String txt_cantidad2="";
public void opcionCantidadM(){
        if(!cb_cantidad.isSelected()){
        txt_cantidad=" ";
        txt_cantidad2=" ";
        }        
        else{
        txt_cantidad="  cant_pedida>0 and ";
        txt_cantidad2=" where cant_pedida>0 ";
        }
}



    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        muestraTodos();
    }//GEN-LAST:event_jButton1ActionPerformed
  public void muestraTodos(){
   
    //Toma la Categoria:
        txt_buscar.setText("Mostrar Todos");
        ResultSet respuesta=null;
        //Segun Categoria o Muestra Todos los Productos.

        respuesta=conexion.consultarBase("SELECT cod_producto,nombre,descripcion,precio,cantidad FROM itm_pedreposicion where cod_pedido="+txt_cod.getText()+";");


     cargarImagenes(respuesta);
     txt_numero.setText(String.valueOf(conexion.obtenerFilas(respuesta)));
    }
    private void txt_buscarKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_buscarKeyTyped
        // TODO add your handling code here:
        int t=evt.getKeyChar();
        String parametro=txt_buscar.getText().toString();
        if(txt_buscar.getText().equals("")){
        parametro="%";
        }
        String itemBuscar="'"+parametro+"'";
        if(t==10){
           System.gc(); 
           muestraBusqueda(itemBuscar);
        }
        
        
    }//GEN-LAST:event_txt_buscarKeyTyped

    private void txt_codActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt_codActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txt_codActionPerformed

    private void cb_cantidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_cantidadActionPerformed
        // TODO add your handling code here:
        opcionCantidadM();
}//GEN-LAST:event_cb_cantidadActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        //Agrego una factura de compra al panel.
        //Lleno con los datos que necesito

        //Imprimo el pedido web:
        Imprimir TrabImpresion=new Imprimir(this,txt_cod.getText());
        TrabImpresion.escriboFact(" Lista de Pedido de Reposicion");
        TrabImpresion.escriboFact("\nCodigo Pedido:"+txt_cod.getText());
        TrabImpresion.escriboFact("Local:"+txt_bod.getText()+"\n");


        TrabImpresion.escriboFact(TrabImpresion.pongoTitulos(""));


        ResultSet rs=conexion.consultarBase("SELECT cod_producto,nombre,descripcion,precio,cantidad FROM itm_pedreposicion where cod_pedido="+txt_cod.getText()+";");
        try {
            rs.beforeFirst();
            while(rs.next()){
                String codigo=rs.getString(1);
                String nombre=rs.getString(2);
                String descripcion=rs.getString(3);
                String  precio=String.valueOf(rs.getDouble(4));
                String cantidad=String.valueOf(rs.getInt(5));

                TrabImpresion.insertoDetImp(codigo,nombre,cantidad,precio,"0");
            }
        } catch (SQLException ex) {
            Logger.getLogger(pedidoReposicion.class.getName()).log(Level.SEVERE, null, ex);
        }

        TrabImpresion.escriboFact("###############################");
        TrabImpresion.printString(TrabImpresion.texto);


    }//GEN-LAST:event_jButton2ActionPerformed

 
    public void muestraBusqueda(String itemBuscar){
        
        ResultSet respuesta=null;
        
        
        String palabDesc[]=separaOraciones(itemBuscar);;
        
        String cons1="";
        String cons2="";
        
        for(int j=0;j<palabDesc.length;j++){
            
            if(palabDesc[j].equals("")||palabDesc[j].equals(" ")) {
                
            } else{
                
                System.out.println("la palabra es:"+palabDesc[j]);
                
                String fin=" ; ";
                if(palabDesc.length!=1){
                    fin=" union ";
                }
                
                if(palabDesc.length==j+1){
                    fin=" ; ";
                }
                
                System.out.println("Entra en el for:"+j+" |"+palabDesc.length+" veces."+fin);

                //SELECT cod_producto,nombre,descripcion,precio,cantidad FROM itm_pedreposicion where cod_pedido=1;
                cons1=cons1+"SELECT cod_producto,nombre,descripcion,precio,cantidad " +
                        "FROM itm_pedreposicion  " +
                        "where  "+txt_cantidad+"  ( lcase(cod_producto) like lcase('%"+palabDesc[j]+"%') or lcase(nombre) like lcase('%"+palabDesc[j]+"%') or precio="+palabDesc[j]+" )    ) "+fin;

                 cons2=cons2+"SELECT cod_producto,nombre,descripcion,precio,cantidad " +
                        "FROM itm_pedreposicion " +
                        "where "+txt_cantidad+" ( lcase(cod_producto) like lcase('%"+palabDesc[j]+"%') or lcase(nombre) like lcase('%"+palabDesc[j]+"%' )     ) "+fin;


                
            }
        }
        
        
        
        
        //Realizo la consulta
        try{
            Integer.parseInt(itemBuscar);
            // respuesta=conexion.consultarBase("select * from producto  where ( lcase(cod_producto) like lcase('%"+itemBuscar+"%') or lcase(nombre) like lcase('%"+itemBuscar+"%') or stock_total="+itemBuscar+" or precio_normal="+itemBuscar+" ) ;");
            respuesta=conexion.consultarBase(cons1);
        } catch(java.lang.NumberFormatException e){
            //respuesta=conexion.consultarBase("select * from producto where ( lcase(cod_producto) like lcase('%"+itemBuscar+"%') or  lcase(nombre) like lcase('%"+itemBuscar+"%')) ;");
            respuesta=conexion.consultarBase(cons2);
        }
        
        
        
        cargarImagenes(respuesta);
        txt_numero.setText(String.valueOf(conexion.obtenerFilas(respuesta)));
        
    }
    
    public void cargarImagenes(ResultSet r){
        //Configuro Variables iniciales
        contenedor.removeAll();
        this.sc_principal.remove(contenedor);

        //Creo los punteros:
        //limpio Banderas:
        punteroX=0;
        punteroY=0;
        contadorImagenes=0;
        filasImagenes=0;
        cantidadPosIMG=0;

        try {
            r.beforeFirst();
        filasImagenes=0;
        while(r.next()){
        String codigo=r.getString(1);
        String nombre=r.getString(2);
        String descripcion=r.getString(3);
      
        double precio=r.getDouble(4);
        int cant_pedida=r.getInt(5);

        Img_PanelProd ipp=new Img_PanelProd(this,bodega,this.txt_cod.getText());
        //Agrego los Datos:
        ipp.lbl_codigo.setText(codigo);
        ipp.txt_nombre.setText(nombre);
        ipp.txt_descripcion.setText(descripcion);
        ipp.txt_precio.setText(String.valueOf(precio));
        ipp.txt_ped.setText(String.valueOf(cant_pedida));

        //cargo la imagen

        javax.swing.ImageIcon imagen=new javax.swing.ImageIcon("C:\\imagenesweb\\"+codigo+".gif");
        ipp.lbl_imagen.setIcon(imagen);



        agregarPro_Panel(ipp,contenedor);


        }
       
        JScrollBar vertical=this.sc_principal.getVerticalScrollBar();
        vertical.setUnitIncrement(10);
        this.sc_principal.setVerticalScrollBar(vertical);
        this.sc_principal.repaint();
        this.sc_principal.updateUI();

        
            
    } catch (SQLException ex) {
            Logger.getLogger(pedidoReposicion.class.getName()).log(Level.SEVERE, null, ex);
        }
    
    
    }

    int punteroX=0;
    int punteroY=0;
    int anchoImagen=240;
    int altoImagen=450;
    int contadorImagenes=0;
    int filasImagenes=0;
    int cantidadPosIMG=0;

    public void agregarPro_Panel(Img_PanelProd ipp,javax.swing.JPanel contenedor){
    int anchoTotal=contenedor.getWidth();
    cantidadPosIMG=Integer.valueOf(nf.format(anchoTotal/anchoImagen));
   // System.out.println("El ancho del contenedor es:"+anchoTotal+" se puede poner:"+ cantidadPosIMG+" imagenes.");
        
        
        ipp.setBounds(punteroX, punteroY, anchoImagen, altoImagen);
        contenedor.add(ipp);
        contadorImagenes++;
        punteroX=punteroX+anchoImagen;

        if(contadorImagenes==cantidadPosIMG){
        contadorImagenes=0;
        punteroX=0;
        punteroY=punteroY+altoImagen;
        filasImagenes++;

        }
        Dimension psize=new Dimension();
        psize.height=(altoImagen*filasImagenes)+318;
        psize.width=cantidadPosIMG*anchoImagen;
        contenedor.setPreferredSize(psize);
        
    
    }

    
    
    
    
    
    
    
  public String[] separaOraciones(String oracionEnt){

    oracionEnt=oracionEnt+"'";
     
     boolean b1=false;
     boolean b2=false;
      int p1=0;
      int p2=0;
     boolean oracion=false;
     
     int ban1=0;
     int ban2=0;
     
     String[] vectorNormal=new String[20];
     String[] vectorOracion=new String[20];
     
     int numeroCor=0;
     System.out.println(oracionEnt);
     for(int i=0;i<oracionEnt.length();i++){
     p2++;
         String caracter=String.valueOf(oracionEnt.charAt(i)); 
         if(caracter.equals("'"))
         {
        
          if(b1){
                 b1=false;
                 b2=false;
                 numeroCor++;
             }else{
                 b1=true;
                 oracion=true;
                 
             }
             int pfin=p2-2;
             System.out.println("p1="+p1+" "+"p2="+pfin); 
              //Guardo en vectores:
             
             int pf=p2-1;
             if(!oracion){
             System.out.println("Guardo esta!!");
             vectorOracion[ban2]=oracionEnt.substring(p1,pf);
             ban2++;
             }else{
             vectorNormal[ban1]=oracionEnt.substring(p1,pf);
             ban1++;        
             }
             
             oracion=false;
             
             
              p1=p2;
              p2=p2; 
         }else{
         
         System.out.println("["+i+"]="+caracter+":");
         
         }
     
     }
     System.out.println("# Oraciones:"+numeroCor);
     
//     muestraVector(vectorOracion);
//     muestraVector(vectorNormal);
     
     java.util.Vector vector=new java.util.Vector();
     for(int i=0;i<vectorOracion.length;i++){
         try{
         if(vectorOracion[i].equals("") || vectorOracion[i]==null){}
         else{
             vector.add(vectorOracion[i]);
         }
         }catch(Exception e){}
     }
     
     for(int i=0;i<vectorNormal.length;i++){
     try{
         if(vectorNormal[i].equals("") || vectorNormal[i]==null){}
         else{
             String pal=vectorNormal[i];
             String[] palabras=pal.split(" ");
             for(int j=0;j<palabras.length;j++){
//             if(palabras[j].equals("") && palabras[j]==null){}
//             else{
                 
                 System.out.println("Guarda:"+palabras[j]+":");
             vector.add(palabras[j]);
//             }
             }
         }
     }catch(Exception e){}
         
         }
    
     
     String[] respuesta=new String[vector.size()];
     for(int i=0;i<respuesta.length;i++){
        respuesta[i]=vector.get(i).toString();
     }
     return(respuesta);
     
    }



 

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox cb_cantidad;
    public javax.swing.JPanel contenedor;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane sc_principal;
    private javax.swing.JTextField txt_bod;
    private javax.swing.JTextField txt_buscar;
    public javax.swing.JTextField txt_cod;
    private javax.swing.JTextField txt_fecha;
    private javax.swing.JLabel txt_numero;
    // End of variables declaration//GEN-END:variables

}
